package yeliuhuishi.WordCount.basics;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class myMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //切割字符串
        String line = value.toString();
        String[] characters = line.split(" ");
        //将数据以key-value的形式传出map
        //Context:  上下文,是全局的,可以在全局范围内执行功能
        for (String s : characters) {
            context.write(new Text(s), new IntWritable(1));
        }
    }
}